import csv

with open('bz_device_object_id_and_name.csv', 'w') as device_output:
    device_writer = csv.writer(device_output, delimiter=',')

    with open('bz_clean_device.data') as device_file:
        device_reader = csv.reader(device_file, delimiter='\t')

        for index, row in enumerate(device_reader):
            device_writer.writerow([row[0], row[2]])

    with open('bz_power_device.data') as power_file:
        power_reader = csv.reader(power_file, delimiter='\t')

        for index, row in enumerate(power_reader):
            if index == 0: continue  # Skip the header.
            device_writer.writerow([row[0], row[4]])
